<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../before/css/common.css" rel="stylesheet" tyle="text/css" />
    <link href="../before/css/style.css" rel="stylesheet" type="text/css" />
    <link href="../before/fonts/iconfont.css" rel="stylesheet" type="text/css" />
    <script src="../after/js/jquery-2.1.1.min.js"></script>
    <link rel="stylesheet" href="/after/css/laypage.css">
    <link rel="stylesheet" type="text/css" href="../before/h-ui/css/H-ui.min.css" />
    <script type="text/javascript" src="../before/h-ui/js/H-ui.js"></script>
    <script type="text/javascript" src="../after/js/vue/vue.min.js"></script>
    <script src="../before/js/jquery.SuperSlide.2.1.1.js" type="text/javascript"></script>
    <script src="../before/js/common_js.js" type="text/javascript"></script>
    <script src="../before/js/footer.js" type="text/javascript"></script>
    <script src="../before/js/jquery.jumpto.js" type="text/javascript"></script>
    <script type="text/javascript" src="/after/js/laypage/laypage.js" charset="utf-8"></script>
    <script type="text/javascript" src="/after/js/layer/layer.js" charset="utf-8"></script>
    <title>用户订单列表</title>
</head>
<script>
    var getUser = function() {
        $.ajax({
            url : "/address/getUser.do",
            type : "POST",
            dataType : "json",
            success : function(msg) {
                console.log(msg)
                if(msg.hashMap.user==null){
                    top.location.href="HJHStageLogin.ftl";
                }
            }
        });
    }
    getUser();

</script>
<body>

        <div class="Order_form">
            <div class="user_Borders">
                <div class="title_name">
                    <span class="name">我的评论</span>
                </div>
                <div class="Order_form_list">
                    <table  id="app">
                        <thead>
                         <tr>
                             <td>书名</td>
                             <td>评论</td>
                             <td>评分</td>
                             <td>操作</td>
                         </tr>
                        </thead>
                        <tbody v-for="(item,index) in result">
                        <tr><td colspan="6" class="Order_form_time">{{new Date(item.messDate).toLocaleString()}}</td></tr>
                        <tr>
                            <td >

                                            <!-- <a href="#" class="product_img"><img :src="'../before/pic/'+item.book.picture" width="80px" height="80px"></a>-->
                                              <a href="#">{{item.book.name}}</a>
                            </td>
                                 <td>
                                     {{item.messWord}}
                                 </td>
                            <td>{{item.score}}</td>
                            <td class="operating">

                                <a href="#" onclick="del(this.name)"  :name="item.id">删除</a>
                            </td>
                        </tr>

                        </tbody>
                    </table>
                    <div id="pagenav"></div>
                </div>
            </div>

        </div>
<!--底部样式-->

</body>
</html>

<script type="text/javascript">

    function del(obj){
        $.ajax({
            url : "/order/dellmess.do",
            type : "POST",
            dataType : "json",
            data : {
                id:obj
            },
            error:function () {
                alert("删除失败");
            },
            success : function(msg) {
                getUserPageList();
            }

        })
    }

    var app = new Vue({
        el : '#app',
        data : {
            result : []
        }
    });
    //查询用户数据
    var getUserPageList = function(curr) {
        $.ajax({
            url : "/order/getmess.do",
            type : "POST",
            dataType : "json",
            data : {
                pageNum:curr || 1,
                pageSize:4,
            },
            success : function(msg) {
                app.result=msg.list;
                console.log(msg)
                laypage({
                    cont : 'pagenav', //容器。值支持id名、原生dom对象，jquery对象,
                    pages :msg.totlpage, //总页数
                    skin:'#CD00CD',
                    first : '首页',
                    last : '尾页',
                    curr : curr || 1, //当前页

                    jump : function(obj, first) { //触发分页后的回调

                        if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr

                            getUserPageList(obj.curr);

                        }
                    }
                });
            }
        });
    }

    getUserPageList();

</script>

